#include "framegeneratorplugin.h"

#include <KPluginFactory>
#include <KPluginLoader>

#include <kdclib.h>

class FrameGeneratorPlugin;

K_PLUGIN_FACTORY( KDCMenuPluginFactory, registerPlugin< FrameGeneratorPlugin >(); )
K_EXPORT_PLUGIN( KDCMenuPluginFactory( "FrameGeneratorPlugin" ) )

#include <interfaces/kdcapplicationinterface.h>
KDCApplicationInterface *gKDCApplicationInterface;

FrameGeneratorPlugin::FrameGeneratorPlugin( QObject *parent, const QVariantList &args ) : KDCPluginInterface( parent ), pInfo( KPluginInfo("framegeneratorplugin.desktop", "services") ), pInterfaces( NULL ), pImpl( NULL )
{
	Q_UNUSED( args );
	gKDCApplicationInterface = NULL;
}

FrameGeneratorPlugin::~FrameGeneratorPlugin()
{
	unload();
}

QString FrameGeneratorPlugin::interfaceName() const
{
	return "FrameGeneratorPlugin";
}

const KPluginInfo& FrameGeneratorPlugin::info() const
{
	return pInfo;
}

QWidget* FrameGeneratorPlugin::widget() const
{
	return NULL;
}

KDCConfigPageInterface* FrameGeneratorPlugin::configPage() const
{
	return NULL;
}

KDC::Position FrameGeneratorPlugin::tabPosition() const
{
	return KDC::None;
}

bool FrameGeneratorPlugin::load()
{
	if ( pImpl )
		return true;
	pImpl = new FrameGeneratorImpl;
	return true;
}

bool FrameGeneratorPlugin::unload()
{
	if ( !pImpl )
		return true;
	pInterfaces->removeOne( pImpl );
	deletePtr( pImpl );
	return true;
}

bool FrameGeneratorPlugin::setInterfaces( QList<KDCBaseInterface*>& aInterfaces )
{
	pInterfaces = &aInterfaces;
	pInterfaces->append( pImpl );
	return true;
}

bool FrameGeneratorPlugin::init()
{
	foreach( KDCBaseInterface *interface, *pInterfaces )
		if ( interface->interfaceName() == "KDCApplicationInterface" )
		{
			gKDCApplicationInterface = static_cast<KDCApplicationInterface*>( interface );
		}
	return pImpl->init();
}

void FrameGeneratorPlugin::setObject( KDCObject *aObject )
{
	Q_UNUSED( aObject );
}

void FrameGeneratorPlugin::refresh()
{
	
}

KDCObject* FrameGeneratorPlugin::currentObject() const
{
	return NULL;
}

#include "framegeneratorplugin.moc"
